x86/hvm: extend HVM cpuid leaf with vcpu id
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 7 Jan 2015 10:08:49 +0000 (11:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 7 Jan 2015 10:08:49 +0000 (11:08 +0100)
To perform certain hypercalls HVM guests need to use Xen's idea of
vcpu id, which may well not match the guest OS idea of CPU id.
This patch adds vcpu id to the HVM cpuid leaf allowing the guest
to build a mapping.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/include/public/arch-x86/cpuid.h

index 72be5b9f68757fe6d7e2d6f51999fa3472f12b44..e33cd0a7a88c476bf081b822ca75165d72335b13 100644 (file)
@@ -4188,6 +4188,10 @@ void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,
          * foreign pages) has valid IOMMU entries.
          */
         *eax |= XEN_HVM_CPUID_IOMMU_MAPPINGS;
+
+        /* Indicate presence of vcpu id and set it in ebx */
+        *eax |= XEN_HVM_CPUID_VCPU_ID_PRESENT;
+        *ebx = current->vcpu_id;
     }
 }
 
index 6005dfec5299155cdfaaa68b4688c8fd79bbc879..d709340f18d089560b959835eabb7b6609542c7e 100644 (file)
 /*
  * Leaf 5 (0x40000x04)
  * HVM-specific features
+ * EAX: Features
+ * EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
  */
-
-/* EAX Features */
 #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
 #define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
 /* Memory mapped from other domains has valid IOMMU entries */
 #define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
+#define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
 
 #define XEN_CPUID_MAX_NUM_LEAVES 4